package Com.javaserver.servlet;


import Com.javaserver.dao.staffserver;
import Com.javaserver.utils.DB;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/stalist")
public class ShowStaffserverlet extends HttpServlet {
    staffserver staffed = new staffserver();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String page=req.getParameter("page");
        if(page==null){
            page="1";
        }
        List<Map<String, Object>> list = DB.executeQuery("select count(*) count from staff");
        req.getSession().setAttribute("userLen", list.get(0).get("count"));
        req.getSession().setAttribute("stalist", staffed.stalist(Integer.parseInt(page)));
        req.getSession().setAttribute("nav", "员工查询");
        resp.sendRedirect(req.getContextPath() + "/StaffManagement.jsp");

    }
}
